#include <stdlib.h>
#include <stdio.h>
#include "UI_Logic_API.h"

int main(int argc, char* argv[]){
    init();
    loadAI(argv[1], 1);
    loadAI(argv[2], 2);
    int turnCount, seed;
    sscanf(argv[3], "%d", &turnCount);
    seed = -1;
    if (argc >= 5) sscanf(argv[4], "%d", &seed);
    srand(seed);
	int i;
    char* result = malloc(12000000);
    for (i = 0; i < turnCount; ++ i){
        printf("Round %d\n", i);
        fflush(stdout);
        invokeAI();
        run();
        if (checkWin() != -1) break;
    }
    char* replay = malloc(120000000);
    getReplay(replay);
    FILE* fout = fopen("replay.json","w");
    fprintf(fout, "%s\n", replay);
    fclose(fout);
}